<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .current {
        background-color: pink;
      }
      .content div {
        display: none;
      }
    </style>
  </head>
  <body>
    <button class="current">语文</button>
    <button>数学</button>
    <button>英语</button>
    <div class="content">
      <div class="item" style="display: block">chinese</div>
      <div>math</div>
      <div>english</div>
    </div>
  </body>
  <script src="./js/jquery.min.js"></script>
  <script>
    var index = 0;
    $(function () {
      $("button").on("mouseenter", function () {
        $(this).addClass("current").siblings().removeClass("current");
        index = $(this).index();
        $(".content div").eq(index).show().siblings().hide();
      });
      var timer = setInterval(function () {
        index++;
        if (index >= 3) {
          index = 0;
        }
        $("button")
          .eq(index)
          .addClass("current")
          .siblings()
          .removeClass("current");
        $(".content div").eq(index).show().siblings().hide();
      }, 1000);
      $("button").hover(
        function () {
          clearInterval(timer);
        },
        function () {
          timer = setInterval(function () {
            index++;
            if (index >= 3) {
              index = 0;
            }
            $("button")
              .eq(index)
              .addClass("current")
              .siblings()
              .removeClass("current");
            $(".content div").eq(index).show().siblings().hide();
          }, 1000);
        }
      );
    });
  </script>
</html>
